<!--
 * @Author: 梁青春
 * @Date: 2025-11-06 10:41:22
 * @LastEditTime: 2025-11-06 10:53:54
 * @LastEditors: 梁青春
-->
<template>
  <slot :print="print" />
</template>

<script setup>
import { h } from 'vue'
import { printVNode } from './utils/printFrame'
import A4Record from './templates/a4Record.vue'

const props = defineProps({
  type: { type: String, required: true }, // a4
  data: { type: Object, required: true }
})

const cfg = {
  a4: { width: '210mm', height: '297mm', landscape: false }
}

async function print() {
  const comp = { a4: A4Record }[props.type]
  const vnode = h(comp, { data: props.data })
  await printVNode(vnode, cfg[props.type])
}

defineExpose({ print })
</script>
